<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Home\Home;
use App\Models\Home\Category;

class CategoryController extends Controller
{
    public function index(Home $art,Category $cate,$cid){

        $category = $cate->getCateId($cid);
        $art_list = $art->orderby('updated_at','DESC')->whereIn('article_category.id',$category)
            ->select('article.*','admin_users.name as author','article_category.name as cate_name','tag.tag_name')
            ->join('admin_users','admin_users.id','=','article.user_id')
            ->leftJoin('article_category','article_category.id','=','article.cate_id')
            ->leftJoin('tag','tag.id','=','article.tag_id')
            ->Paginate(15);
        return view('Home.category',compact('art_list'));
    }
}
